<%--
    Document   : subjects
    Created on : Mar 28, 2013, 12:23:21 AM
    Author     : Shuvo
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="java.util.List, java.util.ArrayList, dto.LoggedUser, util.*"%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <%  LoggedUser loggedUser = (LoggedUser) session.getAttribute("user");
                    if (loggedUser != null) {%>
        <div class="sidebar_box">
            <% List<String> subjects = loggedUser.getSubjects();
            boolean isAdmin = Constants.Admin.equalsIgnoreCase(loggedUser.getType());
            if (subjects != null && !subjects.isEmpty()) {
            if(isAdmin) { %>
            <h2>All Subjects:</h2>
            <%} else { %>
            <h2><a href="discuss.jsp"><u>Ask Question</u></a></h2>
            <h2>Your Subjects:</h2> <%}%>
            <ul class="list_01">
                <% for (int i = 0; i < subjects.size(); i++) {
                    String subject = subjects.get(i).replaceAll("&", "~AND~");%>
                <li><%=subjects.get(i)%>
                    <ul class="list_02">
                        <li>
                            <a href="discuss.jsp?subject=<%=subject%>&status=Approved">View Approved Questions</a>
                        </li>
                        <li>
                            <a href="discuss.jsp?subject=<%=subject%>&status=Open">View Open Questions</a>
                        </li>
                        <li>
                            <a href="discuss.jsp?subject=<%=subject%>&status=Rejected">View Rejected Questions</a>
                        </li>
                    </ul>
                </li>
                <%}%>
            </ul>
            <%} else {%>
            <h4>Your subjects are not yet registered.</h4>
            <%}%>
        </div>
        <div class="sidebar_box_bottom"></div>
        <%}%>
    </body>
</html>
